/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.service;

import br.ufc.quixada.adrs.dao.DoencaDAO;
import br.ufc.quixada.adrs.model.Doenca;
import br.ufc.quixada.adrs.util.Msg;
import java.sql.SQLException;
import java.util.List;
import org.slf4j.LoggerFactory;

/**
 *
 * @author Balthazar
 */
public class DoencaService {

    private final DoencaDAO dao = new DoencaDAO();

    public void insertDoenca(Doenca doenca) {
        try {
            dao.insert(doenca);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
    }

    public void deleteDoenca(Long id) {
        try {
            dao.deleteByQuestionarioSanitarioId(id);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
    }

    public List<Doenca> getDoencasByQuestionarioSanitarioId(Long id) {
        try {
            return dao.getByQuestionarioSanitarioId(id);
        } catch (SQLException ex) {
            LoggerFactory.getLogger(this.getClass()).error(Msg.EXCEPTION_MESSAGE, this.getClass().getSimpleName(), ex);
        }
        return null;
    }
}
